<include file="Public/head"/>
<body class="no-skin">
<include file="Public/header"/>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <include file="Public/sidebar"/>
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <include file="Public/breadcrumbs"/>

            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">
                <include file="Public/set"/>

                <!-- /section:settings.box -->
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <form class="form-horizontal" action="{:U('update')}" name="myfromSubmit" method="post" onsubmit="return validateCallback(this)">

                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-4"> sku </label>
                                <div class="col-sm-9">
                                    <input type="text" name="arr[sku]"    datatype="/P.+?$/,s8-16" errormsg="昵称至少8个字符,最多16个字符！" id="sku" class="rcol-xs-10 col-sm-5" value="{$goods.sku}">
                                    <button class="btn btn-sm btn-inverse col-sm-1 pull" type="button">拉取数据</button>
                                     <span class="help-inline col-sm-3">
							<span class="middle" id="sku_middle">sku必须P开头,长度不低于8位</span>
					</span>
                                </div>
                                    
                            </div>
            
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-1"> 商品名 </label>
                                <div class="col-sm-9">

                                    <input type="text" name="arr[name]" id="name" datatype="*" nullmsg="商家名称不能为空" class="rcol-xs-10 col-sm-5" value="{$goods.name}" autocomplete="off" data-bv-notempty />

                                    <input type="hidden" name="id" value="">
                                 
                                </div>
                            </div>

                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-10"> 所属品牌 </label>
                                <div class="col-sm-9">

                                        <select id="goods_brand_id" name="arr[goods_brand_id]" class="rcol-xs-10 col-sm-5">
                                            <volist name="goods_brand" id="val">
                                                <option value="{$val['id']}"
                                                <if condition="$val['id'] eq $goods['goods_brand_id']">selected="selected"
                                                </if>
                                                >{$val['name']}</option>
                                            </volist>
                                        </select>

                                </div>
                            </div>

                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-10">
                                    商品分类 </label>
                                <div class="col-sm-9">
                                    <input type="hidden" id="goods_type" value="{$goods.goods_type_id}">
                                    <select id="goods_type_id" name="arr[goods_type_id]" class="rcol-xs-10 col-sm-5">
                                         <option value="0">请选择商品类别</option>
                                                      
                                                        {$select_option_list}
                                                     
                                    </select>
                                    <span class="help-inline col-xs-12 col-sm-7">
												<span class="middle">请重新选择商品分类</span>
											</span>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-4"> 缩略图 </label>
                                <div class="col-sm-9">
                                    <div class="col-xs-10 col-sm-5">{:UpImage1("pic_thumb",100,100,$goods['pic_thumb'])}</div>
                                    <span class="help-inline col-xs-12 col-sm-7">
												<span class="middle">仅支持jpg、gif、png、bmp、jpeg，且小于1MB。</span>
											</span>
                                </div>
                            </div>

                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-4"> 市场价 </label>
                                <div class="col-sm-9">
                                   <input type="text" name="arr[price_market]"   datatype="*" nullmsg="市场价不能为空" class="rcol-xs-10 col-sm-5" value="{$goods.price_market}">
                                </div>
                            </div>

                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-4"> 成本价 </label>
                                <div class="col-sm-9">
                                   <input type="text" name="arr[price_cost]"  datatype="*" nullmsg="成本价不能为空" class="rcol-xs-10 col-sm-5" value="{$goods.price_cost}">
                                </div>
                            </div>


							 <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-4"> 销售价 </label>
                                <div class="col-sm-9">
                                   <input type="text" name="arr[price]" id="price" datatype="*" nullmsg="销售价不能为空" class="rcol-xs-10 col-sm-5" value="{$goods.price}">
                                </div>
                            </div>

                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-4"> 库存 </label>
                                <div class="col-sm-9">
                                    <input type="number" name="arr[stock_num]" datatype="*" nullmsg="库存不能为空" class="rcol-xs-10 col-sm-5" value="{$goods.stock_num}">
                                </div>
                            </div>
                            
                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-4"> 重量 </label>
                                <div class="col-sm-9">
                                    <input type="number" name="arr[weight]" id="weight" datatype="*" nullmsg="重量不能为空" class="rcol-xs-10 col-sm-5" value="{$goods.weight}">
                                </div>
                            </div>

                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-4"> 商品关键词 </label>
                                <div class="col-sm-9">
                                    <input type="text" name="arr[info_keywords]" datatype="*" nullmsg="商品关键词不能为空"  class="rcol-xs-10 col-sm-5" value="{$goods.info_keywords}">
                                    <span class="help-inline col-xs-12 col-sm-7">
                                             <span class="middle">商品关键词请以、隔开</span>
                                     </span>
                                </div>
                                
                            </div>

                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-4"> 原产国 </label>
                                 <div class="col-sm-9">
                                        <select id="made_in" name="arr[made_in]" class="rcol-xs-10 col-sm-5">
                                           <foreach name="country" item="co" key="k">
                                                 <option value="{$co['country_id']}"  <if condition="$goods.made_in eq $co['country_id']">selected="selected"</if>>{$co['chinese_name']}</option>
                                           </foreach>
                                        </select>
                                </div>
                            </div>

                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-4"> 关税 </label>
                                <div class="col-sm-9">
                                    <input type="text" name="arr[tax_gw]" datatype="*" nullmsg="关税不能为空"  class="rcol-xs-10 col-sm-5" value="{$goods.tax_gw}">
                                </div>
                            </div>

                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-4"> 消费税 </label>
                                <div class="col-sm-9">
                                    <input type="text" name="arr[tax_xf]" datatype="*" nullmsg="消费税不能为空" class="rcol-xs-10 col-sm-5" value="{$goods.tax_xf}">
                                </div>
                            </div>

                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-4"> 增值税务 </label>
                                <div class="col-sm-9">
                                    <input type="text" name="arr[tax_added]" datatype="*" nullmsg="增值税务不能为空" class="rcol-xs-10 col-sm-5" value="{$goods.tax_added}">
                                </div>
                            </div>
                            <div class="space-4"></div>
                                <div class="form-group">
                                    <label class="col-sm-1 control-label no-padding-right" for="form-field-4"> 贸易模式 </label>
                                     <div class="col-sm-9">
                                            <select id="trade_type" name="arr[trade_type]" class="rcol-xs-10 col-sm-5">
                                               <foreach name="tradeList" item="tr" key="k">
                                                     <option value="{$tr['code']}"  <if condition="$goods.trade_type eq $tr['code']">selected="selected"</if>>{$tr['name']}</option>
                                               </foreach>
                                            </select>
                                    </div>
                                </div>
                            
                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-4"> 税号 </label>
                                <div class="col-sm-9">
                                    <input type="text" name="arr[tax_no]" id="tax_no"  datatype="*" nullmsg="税号不能为空"  class="rcol-xs-10 col-sm-5" value="{$goods.tax_no}">
                                </div>
                            </div>

                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-2"> Pc端描述信息</label>
                                <div class="col-sm-9">
                                    <textarea name="arr[info_pc]"  id="info_pc" placeholder="Pc端描述信息" class="col-xs-10 col-sm-5"
                                              rows="5">{$goods.info_pc}</textarea>
                                    <span class="help-inline col-xs-12 col-sm-7">
												<span class="middle"></span>
											</span>
                                </div>
                            </div>

                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-2"> 移动端描述信息</label>
                                <div class="col-sm-9">
                                    <textarea name="arr[info_mobile]" id="info_mobile" placeholder="移动端描述信息" class="col-xs-10 col-sm-5"
                                              rows="5">{$goods.info_mobile}</textarea>
                                    <span class="help-inline col-xs-12 col-sm-7">
												<span class="middle"></span>
											</span>
                                </div>
                            </div>

                            <div class="space-4"></div>
                            <div class="form-group">
                                <label class="col-sm-1 control-label no-padding-right" for="form-field-2"> 商品备注信息</label>
                                <div class="col-sm-9">
                                    <textarea name="arr[info_notice]" id="info_notice" placeholder="商品备注信息" class="col-xs-10 col-sm-5"
                                              rows="5">{$goods.info_notice}</textarea>
                                    <span class="help-inline col-xs-12 col-sm-7">
												<span class="middle"></span>
											</span>
                                </div>
                            </div>

                            <div class="space-4"></div>
                            <input name="id" value="{$goods.id}" type="hidden">
                            <div class="col-md-offset-2 col-md-9">
                                <button class="btn btn-info" type="submit">
                                    <i class="icon-ok bigger-110"></i>
                                    提交
                                </button>

                                &nbsp; &nbsp; &nbsp;
                                <button class="btn" type="reset">
                                    <i class="icon-undo bigger-110"></i>
                                    重置
                                </button>
                            </div>
                        </form>
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->
    <include file="Public/footer"/>

</div><!-- /.main-container -->

<include file="Public/footerjs"/>
<!-- inline scripts related to this page -->
<script src="__PUBLIC__/qwadmin/js/date-time/bootstrap-datepicker.js"></script>
<script src="__PUBLIC__/qwadmin/js/function.js"></script>
<script type="text/javascript">
          var goods_type_id = $('#goods_type').val();
        if(goods_type_id){
            $('#goods_type_id option').each(function(){
                  if( goods_type_id == $(this).attr('value') ) {
                      $(this).attr('selected' , true);
                      return false;
                  } 
               }); 
        }
    
    jQuery(function ($) {

        var editor = KindEditor.create('textarea[id="info_mobile"]', {
            uploadJson: '__PUBLIC__/kindeditor/php/upload_json.php',
            fileManagerJson: '__PUBLIC__/kindeditor/php/file_manager_json.php',
            allowFileManager: true,
            afterBlur: function () {
                this.sync();
            }
        });

        var editor = KindEditor.create('textarea[id="info_pc"]', {
            uploadJson: '__PUBLIC__/kindeditor/php/upload_json.php',
            fileManagerJson: '__PUBLIC__/kindeditor/php/file_manager_json.php',
            allowFileManager: true,
            afterBlur: function () {
                this.sync();
            }
        });

        var editor = KindEditor.create('textarea[id="info_notice"]', {
            uploadJson: '__PUBLIC__/kindeditor/php/upload_json.php',
            fileManagerJson: '__PUBLIC__/kindeditor/php/file_manager_json.php',
            allowFileManager: true,
            afterBlur: function () {
                this.sync();
            }
        });
        $('#birthday').datepicker({
            format: 'yyyy-mm-dd',
            weekStart: 1,
            autoclose: true,
            todayBtn: 'linked',
            language: 'cn'
        });
        
        $("#goods_brand_id").comboSelect();
        $("#goods_type_id").comboSelect();
    });
</script>


                
<!--       拉取sku的商品信息    -->
                            <script>
                                $(".pull").click(function(){
                                    var sku = $("#sku").val(); 
                                   if(sku.length < 8){
                                        $("#sku_middle").html("<p style='color:red;'>sku长度不能低于8位</p>");
                                        return flase;
                                    }else if(sku.match(/^(?!P).*$/) != null){
                                        $("#sku_middle").html("<p style='color:red;'>sku请大写P字母开始</p>");
                                        return flase;
                                    }
                                    $.post("{:U('pull')}",{sku:sku},function(data){
                                        if(data.errno == 0)
                                        {
                                            $("#name").val(""+data['data'][0]['name']+"");
                                            $("#price").val(""+data['data'][0]['price']+"");
                                            if(data['data'][0]['tax_no']){
                                            $("#tax_no").val(""+data['data'][0]['tax_no']+"");}
                                            $("#weight").val(""+data['data'][0]['weight']+"");
                                            $("#sku_middle").html("<p style='color:red;'>"+data.msg+"</p>");
                                        }
                                        else{
                                            $("#sku_middle").html("<p style='color:red;'>"+data.msg+"</p>");  
                                        }
                                    },'json');
                                })
                            </script>
</body>
</html>
